<?php
namespace Profile\Model;
use Think\Model\RelationModel;
class PracticeModel extends RelationModel{
	protected $_validate=array(
		array('ydq_name','require','活动名不能为空!',1)
		);
	 protected $_auto=array(
        array('ydq_puser','getname',self::MODEL_INSERT,'callback'),
        array('ydq_stunum','getstunum',self::MODEL_INSERT,'callback'),
    	array('ydq_pdate','getdate',self::MODEL_INSERT,'callback'));
	function getdate(){
	    return date('Y-m-d-h-i-s');
    }
    public function getname(){
    if(session('?user')){
        $data=session('user');
        return $data['ydq_username'];
      }
      else
        return 'success';
    }
    public function getstunum(){
    if(session('?user')){
        $data=session('user');
        return $data['ydq_stunum'];
      }
      else
        return 'success';
    }
    protected $_link=array(
        'groups' => array(    
        'mapping_type'  => self::BELONGS_TO,    
        'class_name'    => 'groups', 
        'foreign_key'   => 'ydq_groupname',       
        'mapping_name'  => 'groups',
        'mapping_fields'=> 'ydq_groupname',
        'as_fields'     => 'ydq_groupname'   
        )
        );
}?>